package com.zhumo.sz.controller;


import com.zhumo.sz.common.CommonInsert;
import com.zhumo.sz.common.Result;
import com.zhumo.sz.entity.user.UserInfo;
import com.zhumo.sz.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/sz/service/user")
public class UserController {

    @Autowired
    private UserService userService;


    /**
     * 插入用户信息
     * @return
     */
    @RequestMapping("/add")
    public Result<String> addUser(@RequestParam int num,@RequestParam int flush) {
        CommonInsert<UserInfo> commonInsert = userService.addUser(num,flush);
        if (commonInsert.getNum() == commonInsert.getResult()){
            String message = "成功插入" + commonInsert.getResult() + "条用户信息";
            log.info(message);
            return Result.ok(message);
        }else {
            log.error("插入异常");
            return Result.fail();
        }
    }
}
